package com.suneast.suneaststore.modules.goodsdetail.subfragment;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

import com.suneast.suneaststore.R;
import com.suneast.suneaststore.modules.goodsdetail.event.BottomPageChangeEvent;
import com.suneast.suneaststore.modules.goodsdetail.event.SubCateLoaded;
import com.suneast.suneaststore.ui.fragments.BaseFragment;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class GoodsPackageFragment extends BaseFragment {
    @Override
    public @LayoutRes
    int setLayout() {
        return R.layout.fragment_goods_packaging;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View rootView) {
        EventBus.getDefault().register(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onPageChange(BottomPageChangeEvent event) {
        if (event.getIndex() == 2) {
            EventBus.getDefault().post(new SubCateLoaded());
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBus.getDefault().unregister(this);

    }
}
